﻿<inter:PluginConfigForm x:Class="Convertor.Plugin.SendEmail.ConfigForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:sm="clr-namespace:Wpf.CommonTools.SystemExtension;assembly=Wpf.CommonTools"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:inter="clr-namespace:Convertor.Interface;assembly=Convertor.Interface"
             mc:Ignorable="d">
    <inter:PluginConfigForm.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Convertor;component\Assets\Style.xaml"/>
                <ResourceDictionary Source="/Convertor;component\Assets\Lang\StringResource.en.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.zh.xaml"/>
                <ResourceDictionary Source="Assets\Lang\StringResource.en.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </inter:PluginConfigForm.Resources>
    <DockPanel Width="600" MinHeight="200" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type inter:PluginConfigForm}}, Path=Config}">
        <TabControl DockPanel.Dock="Top">
            <TabItem Header="{DynamicResource Plugin_SendEmail_EmailConfig}">
                <DockPanel>
                    <CheckBox Content="{DynamicResource Plugin_SendEmail_IsSendAsHtml}" DockPanel.Dock="Top"
                              IsChecked="{Binding Path=IsHtml, UpdateSourceTrigger=PropertyChanged}"/>
                    <AdornerDecorator DockPanel.Dock="Top">
                        <TextBox x:Name="tbTitle" Text="{Binding Path=Subject, UpdateSourceTrigger=PropertyChanged}">
                            <sm:WatermarkService.Titlemark>
                                <TextBlock Text="{DynamicResource Plugin_SendEmail_SendSubject}" TextAlignment="Right"></TextBlock>
                            </sm:WatermarkService.Titlemark>
                        </TextBox>
                    </AdornerDecorator>
                    <AdornerDecorator DockPanel.Dock="Top">
                        <TextBox  MinHeight="300" 
                                  Text="{Binding Path=Body, UpdateSourceTrigger=PropertyChanged}"
                                  AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto">
                            <sm:WatermarkService.Titlemark>
                                <TextBlock Text="{DynamicResource Plugin_SendEmail_SendContent}" TextAlignment="Right" VerticalAlignment="Bottom"></TextBlock>
                            </sm:WatermarkService.Titlemark>
                        </TextBox>
                    </AdornerDecorator>
                </DockPanel>
            </TabItem>
            <TabItem Header="{DynamicResource Plugin_SendEmail_EmailHostConfig}">
                <DockPanel>
                    <WrapPanel DockPanel.Dock="Top"  HorizontalAlignment="Right" Margin="0,0,0,2">
                        <Button Padding="10,1" Click="AddTarget_Click">
                            <WrapPanel>
                                <Image Source="Image/Add.png" Width="14"/>
                                <TextBlock  Text="{DynamicResource Add}" Margin="3,0,0,0"/>
                            </WrapPanel>
                        </Button>
                    </WrapPanel>
                    <DataGrid MinHeight="200"
                               DockPanel.Dock="Top" AutoGenerateColumns="False" IsReadOnly="True"
                               ItemsSource="{Binding Path=SmtpClientList}" 
                               GridLinesVisibility="None" AlternatingRowBackground="#FFD6D1D1" CanUserResizeRows="False">
                        <DataGrid.CellStyle>
                            <Style TargetType="DataGridCell">
                                <Setter Property="Padding" Value="3"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type DataGridCell}">
                                            <Border Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                                                <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </DataGrid.CellStyle>
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="{DynamicResource Plugin_SendEmail_Host}" Width="*" Binding="{Binding Host}"/>
                            <DataGridTextColumn Header="{DynamicResource Plugin_SendEmail_Port}" Width="50" Binding="{Binding Port}"/>
                            <DataGridTemplateColumn Header="{DynamicResource Plugin_SendEmail_EnableSsl}" Width="60">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding Plugin_SendEmail_EnableSsl}" IsEnabled="False" HorizontalAlignment="Center"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Header="{DynamicResource Plugin_SendEmail_LoginName}" Width="140" Binding="{Binding LoginName}"/>
                            <DataGridTemplateColumn Header="" Width="42">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Button Template="{StaticResource ButtonWithoutBackground}" Click="ModifyTarget_Click" Tag="{Binding Path=.}" Padding="0">
                                                <Image Source="Image/Edit.png" Width="14"/>
                                            </Button>
                                            <Button Template="{StaticResource ButtonWithoutBackground}" Click="DeleteTarget_Click" Tag="{Binding Path=.}" Padding="0">
                                                <Image Source="Image/Delete.png" Width="14"/>
                                            </Button>
                                        </StackPanel>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </DockPanel>
            </TabItem>
        </TabControl>
        <TextBlock Style="{StaticResource InfoStyle}" DockPanel.Dock="Top" Text="{Binding Path=ToolTip}"/>
    </DockPanel>
</inter:PluginConfigForm>
